﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SuperFox
{
    public partial class ProductMainContainer : UserControl
    {
        public static readonly DependencyProperty TitleProperty =
           DependencyProperty.Register("Title", typeof(String), typeof(ProductMainContainer),
                 new PropertyMetadata("", new PropertyChangedCallback(TitlePropertyChanged)));

        public static readonly DependencyProperty DescriptionProperty =
           DependencyProperty.Register("Description", typeof(String), typeof(ProductMainContainer),
                 new PropertyMetadata("", new PropertyChangedCallback(DescriptionPropertyChanged)));


        public static readonly DependencyProperty ImageProperty =
            DependencyProperty.Register("Image", typeof(ImageBrush), typeof(ProductMainContainer), new PropertyMetadata(null,
                                                new PropertyChangedCallback(ImagePropertyChanged)));



        public String Title
        {
            get { return (String)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }

        public String Description
        {
            get { return (String)GetValue(DescriptionProperty); }
            set { SetValue(DescriptionProperty, value); }
        }

        public ImageBrush Image
        {
            get { return (ImageBrush)GetValue(ImageProperty); }
            set { SetValue(ImageProperty, value); }
        }

        private static void ImagePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as ProductMainContainer).ImageCanvas.Background = e.NewValue as ImageBrush;
        }

        private static void DescriptionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as ProductMainContainer).DescriptionControl.Text = e.NewValue as String;
        }

        private static void TitlePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as ProductMainContainer).TitleControl.Text = e.NewValue as String;
        }

        public ProductMainContainer()
        {
            InitializeComponent();
        }
    }
}
